load("//bazel:tachyon_cc.bzl", "tachyon_cc_library", "tachyon_cc_unittest")

package(default_visibility = ["//visibility:public"])

tachyon_cc_library(
    name = "challenge",
    hdrs = ["challenge.h"],
    deps = [
        "//tachyon/zk/plonk/base:phase",
        "@com_google_absl//absl/strings",
    ],
)

tachyon_cc_library(
    name = "circuit",
    hdrs = ["circuit.h"],
    deps = [
        "//tachyon/zk/plonk/layout:layouter",
        "//tachyon/zk/plonk/layout/floor_planner",
    ],
)

tachyon_cc_library(
    name = "constraint",
    hdrs = ["constraint.h"],
    deps = ["//tachyon/zk/expressions:expression"],
)

tachyon_cc_library(
    name = "constraint_system",
    hdrs = ["constraint_system.h"],
    deps = [
        ":constraint",
        ":gate",
        ":lookup_tracker",
        ":query",
        ":selector_compressor",
        ":virtual_cells",
        "//tachyon/base:logging",
        "//tachyon/base/containers:container_util",
        "//tachyon/base/containers:contains",
        "//tachyon/base/functional:callback",
        "//tachyon/base/strings:string_util",
        "//tachyon/zk/base:row_types",
        "//tachyon/zk/lookup:argument",
        "//tachyon/zk/lookup:type",
        "//tachyon/zk/plonk/expressions/evaluator:cells_querier",
        "//tachyon/zk/plonk/expressions/evaluator:identifier",
        "//tachyon/zk/plonk/expressions/evaluator:selector_replacer",
        "//tachyon/zk/plonk/expressions/evaluator:simple_selector_extractor",
        "//tachyon/zk/plonk/expressions/evaluator:simple_selector_finder",
        "//tachyon/zk/plonk/keys:c_proving_key_impl_forward",
        "//tachyon/zk/plonk/layout:lookup_table_column",
        "//tachyon/zk/plonk/permutation:permutation_argument",
        "//tachyon/zk/plonk/permutation:permutation_utils",
        "//tachyon/zk/shuffle:argument",
        "//tachyon/zk/shuffle:pair",
        "@com_google_absl//absl/container:btree",
        "@com_google_absl//absl/container:flat_hash_map",
        "@com_google_absl//absl/numeric:bits",
    ],
)

tachyon_cc_library(
    name = "exclusion_matrix",
    hdrs = ["exclusion_matrix.h"],
    deps = [
        ":selector_description",
        "//tachyon:export",
        "//tachyon/base/containers:container_util",
    ],
)

tachyon_cc_library(
    name = "gate",
    hdrs = ["gate.h"],
    deps = [
        ":selector",
        ":virtual_cell",
        "//tachyon/zk/expressions:expression",
        "@com_google_absl//absl/strings",
    ],
)

tachyon_cc_library(
    name = "lookup_tracker",
    hdrs = ["lookup_tracker.h"],
    deps = ["//tachyon/zk/expressions:expression"],
)

tachyon_cc_library(
    name = "query",
    hdrs = ["query.h"],
    deps = [
        "//tachyon/base/strings:string_util",
        "//tachyon/zk/base:rotation",
        "//tachyon/zk/plonk/base:column_key",
    ],
)

tachyon_cc_library(
    name = "selector",
    hdrs = ["selector.h"],
    deps = [
        "//tachyon:export",
        "//tachyon/zk/base:row_types",
        "@com_google_absl//absl/hash",
        "@com_google_absl//absl/strings",
    ],
)

tachyon_cc_library(
    name = "selector_assignment",
    hdrs = ["selector_assignment.h"],
    deps = ["//tachyon/zk/expressions:expression"],
)

tachyon_cc_library(
    name = "selector_compressor",
    hdrs = ["selector_compressor.h"],
    deps = [
        ":exclusion_matrix",
        ":selector_assignment",
        ":selector_description",
        "//tachyon/base:parallelize",
        "//tachyon/base/containers:container_util",
        "//tachyon/base/containers:cxx20_erase",
        "//tachyon/base/functional:callback",
        "//tachyon/math/base:parallelize_threshold",
        "//tachyon/zk/expressions:expression_factory",
        "@com_google_googletest//:gtest_prod",
    ],
)

tachyon_cc_library(
    name = "selector_description",
    hdrs = ["selector_description.h"],
    deps = [
        "//tachyon:export",
        "//tachyon/base/containers:adapters",
    ],
)

tachyon_cc_library(
    name = "virtual_cell",
    hdrs = ["virtual_cell.h"],
    deps = [
        "//tachyon:export",
        "//tachyon/zk/base:rotation",
        "//tachyon/zk/plonk/base:column_key",
    ],
)

tachyon_cc_library(
    name = "virtual_cells",
    hdrs = ["virtual_cells.h"],
    deps = [
        ":selector",
        ":virtual_cell",
        "//tachyon/zk/plonk/expressions:expression_factory",
        "//tachyon/zk/plonk/expressions/evaluator:simple_selector_finder",
        "//tachyon/zk/plonk/layout:lookup_table_column",
    ],
)

tachyon_cc_unittest(
    name = "plonk_unittests",
    srcs = [
        "constraint_system_unittest.cc",
        "exclusion_matrix_unittest.cc",
        "selector_compressor_unittest.cc",
        "selector_description_unittest.cc",
        "selector_unittest.cc",
    ],
    deps = [
        ":constraint_system",
        "//tachyon/math/finite_fields/test:finite_field_test",
        "//tachyon/math/finite_fields/test:gf7",
        "@com_google_absl//absl/hash:hash_testing",
    ],
)
